package com.bw.mapper;

import com.bw.bean.Map1;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface VoMapper {
    @Select("SELECT bt.name , sum(oi.total_amount) value FROM base_trademark bt LEFT JOIN order_info oi ON oi.tm_id=bt.id GROUP BY bt.name;")
    List<Map> getList1();

    @Select("SELECT bt.name , sum(total_amount) value FROM base_trademark bt LEFT JOIN order_info oi ON oi.tm_id=bt.id GROUP BY bt.name ORDER BY value desc;")
    List<Map> getList2();

    @Select("SELECT ui.birthday , sum(total_amount)  FROM order_info oi left join user_info ui ON oi.user_id = ui.id\n" +
            "WHERE\n" +
            "ui.birthday>='2000-01-01' && ui.birthday=&;'2010-01-01' and\n" +
            "ui.birthday>='1990-01-01' && ui.birthday=&;'2000-01-01' and\n" +
            "ui.birthday>='1980-01-01' && ui.birthday=&;'1990-01-01';\n")
    List<Map> getList4();


    @Select("SELECT bt.name , ui.gender , sum(total_amount) value FROM base_trademark bt\n" +
            "LEFT JOIN order_info oi ON oi.tm_id=bt.id\n" +
            "LEFT JOIN user_info ui ON oi.user_id=ui.id GROUP BY bt.name , ui.gender;")
    List<Map1> getList3();
}
